package com.sskj.wallet.presenter;

import com.lzy.okrx2.adapter.FlowableBody;
import com.sskj.common.base.HttpData;
import com.sskj.lib.bean.AddressBean;
import com.sskj.lib.http.JsonConverter;
import com.sskj.wallet.bean.AddressListBean;
import com.sskj.wallet.ui.activity.AddressBookActivity;

import java.util.ArrayList;
import java.util.List;

import io.reactivex.Flowable;


public class AddressBookActivityPresenter extends BasePresenter<AddressBookActivity> {

    public Flowable<List<AddressBean>> getAddressList() {
        return httpService.addressList()
                .converter(new JsonConverter<HttpData<AddressListBean>>() {
                })
                .adapt(new FlowableBody<>())
                .map(addressListBeanHttpData -> {
                    HttpData<AddressListBean> httpData = addressListBeanHttpData;
                    List<AddressBean> addressBeans = new ArrayList<>();
                    addressBeans.addAll(httpData.getData().getBtc());
                    addressBeans.addAll(httpData.getData().getEth());
                    return addressBeans;
                });
    }
}
